﻿@using Topro.Entity.Enum;
@{
    Layout = "~/Views/Shared/_Dialog.cshtml";
}
@model Topro.Entity.Response.Product.ProductResponse
<section class="container-fluid" style="background-color: white;">
    <form class="form-horizontal m15_t" id="form">
        <div class="tab-content">
            <input type="hidden" id="Id" name="Id" value="@(Model.Id)">
            <div class="tab-pane fade in active" id="home">
                <div class="form-group">
                    <label class="wd100 control-label"><span class="WdateFmtErr">*</span>物料名称：</label>
                    <div class="wd250 m15_l">
                        <input class="form-control" type="text" name="name" maxlength="40" value="@(Model.Name)" autocomplete="off" placeholder="长度必须介于 2 和 40 之间">
                    </div>
                </div>
                <div class="form-group">
                    <label class="wd100 control-label"><span class="WdateFmtErr">*</span>物料编码：</label>
                    <div class="wd250 m15_l">
                        <input class="form-control" type="text" name="code" maxlength="40" value="@(Model.Code)" autocomplete="off" placeholder="长度必须介于 0 和 40 之间">
                    </div>
                </div>
                <div class="form-group">
                    <label class="wd100 control-label">规格：</label>
                    <div class="wd250 m15_l">
                        <input class="form-control" type="text" name="spec" maxlength="40" value="@(Model.Spec)" autocomplete="off" placeholder="">
                    </div>
                </div>
                <div class="form-group">
                    <label class="wd100 control-label">长mm：</label>
                    <div class="wd250 m15_l">
                        <input class="form-control" type="text" name="length" maxlength="5" value="@(Model.Length.Equals(0)?"":Model.Length.ToString())" autocomplete="off" placeholder="长mm介于 1 和 3 之间正整数">
                    </div>
                </div>
                <div class="form-group">
                    <label class="wd100 control-label">宽mm：</label>
                    <div class="wd250 m15_l">
                        <input class="form-control" type="text" name="width" maxlength="5" value="@(Model.Width.Equals(0)?"":Model.Width.ToString())" autocomplete="off" placeholder="宽mm介于 1 和 3 之间正整数">
                    </div>
                </div>
                <div class="form-group">
                    <label class="wd100 control-label">高mm：</label>
                    <div class="wd250 m15_l">
                        <input class="form-control" type="text" name="height" maxlength="5" value="@(Model.Height.Equals(0)?"":Model.Height.ToString())" autocomplete="off" placeholder="高mm介于 1 和 3 之间正整数">
                    </div>
                </div>
                <div class="form-group">
                    <label class="wd100 control-label">重量：</label>
                    <div class="wd250 m15_l">
                        <input class="form-control" type="text" name="weight" maxlength="5" value="@(Model.Weight.Equals(0)?"":Model.Weight.ToString())" autocomplete="off" placeholder="重量介于 1 和 3 之间正整数">
                    </div>
                </div>
                <div class="form-group">
                    <label class="wd100 control-label">直径mm：</label>
                    <div class="wd250 m15_l">
                        <input class="form-control" type="text" name="diameter" maxlength="5" value="@(Model.Diameter.Equals(0)?"":Model.Diameter.ToString())" autocomplete="off" placeholder="直径mm介于 1 和 3 之间正整数">
                    </div>
                </div>
                <div class="form-group">
                    <label class="wd100 control-label">体积：</label>
                    <div class="wd250 m15_l">
                        <input class="form-control" type="text" name="volume" maxlength="5" value="@(Model.Volume.Equals(0)?"":Model.Volume.ToString())" autocomplete="off" placeholder="体积介于 1 和 3 之间正整数">
                    </div>
                </div>
                <div class="form-group">
                    <label class="wd100 control-label">备注：</label>
                    <div class="wd250 m15_l">
                        <input class="form-control" type="text" name="remark" maxlength="40" value="@(Model.Remark)" autocomplete="off" placeholder="长度必须介于 0 和 40 之间">
                    </div>
                </div>
                <div class="form-group">
                    <label class="wd100 control-label"><span class="WdateFmtErr">*</span>状态：</label>
                    <div class="wd250 m15_l">
                        <label class="m10_r">
                            <input type="radio" name="status" value="1" @(Model.Status.Equals((int)ProductStatus.启用) ? "checked" : "")> 启用
                        </label>
                        <label>
                            <input type="radio" name="status" value="0" @(Model.Status.Equals((int)ProductStatus.禁用) ? "checked" : "")> 禁用
                        </label>
                    </div>
                </div>
            </div>
        </div>
    </form>
</section>
@section footerScript{
    <script type="text/javascript">

        function save() {

            var cover = Topro.UI.Mask({
                obj: $("body"),
                opacity: 0.5
            });

            var data = $("#form").serializeJSON();

            Topro.Util.Ajax({
                type: "POST",
                url: "/Product/Save",
                data: data,
                success: function (res) {
                    if (res.success) {
                        cover.Remove();
                        Topro.UI.DialogOpener().Tip_success("操作成功！");
                        Topro.UI.DialogOpener().page.search();
                        Topro.UI.CloseDialog();
                    } else {
                        cover.Remove();
                        Topro.UI.Tip_short_warning("操作失败！" + res.message);
                    }
                },
                error: function (json) {
                    cover.Remove();
                    Topro.UI.Tip_warning("操作失败！请查看网络，请重试。");
                }
            });

        }
    </script>
}